function instanceOf(instance, cclass) {
  let proto = instance.__proto__;
  let prototype = cclass.prototype;

  while (proto) {
    if (proto === prototype) {
      return true;
    }
    proto = proto.__proto__;
  }

  return false;
}

console.log(instanceOf({ a: 1 }, Object));
console.log(instanceOf({ a: 1 }, Array));

class Person {}
class Student extends Person {}
class Teacher {}
let stu = new Student();

console.log(instanceOf(stu, Student)); // true
console.log(instanceOf(stu, Person)); // true
console.log(instanceOf(stu, Teacher)); // false
